<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
  <head>
  <style>
  a{
  TEXT-DECORATION:none
  }
.fontdaxiao {
	font-size: 12px;
}

.tableAF {
	
}

.tableAF tr th {
	border: 1px;
	border-color: #EDEDED;
	border-style: solid;
}

.tableAF tr td {
	border: 1px;
	border-top: 0px;
	border-color: #EDEDED;
	border-style: solid;
}

.rowsOne {
	background-color: white;
}

.rowsTwo {
	background-color: #7CC5E5;
}

.rowsThree {
	background-color: #F5F5F5;
}
.divc{
	display:inline-block;
    *display:inline;
    zoom:1;
	width:60px;
	height:20px;	
	margin:10px;
	line-height:18px;
	text-align:center;
}
.divb{
	display:inline-block;
    *display:inline;
    zoom:1;
	width:20px;
	height:20px;	
	margin:10px;
	line-height:18px;
	text-align:center;
}
.diva{
	display:inline-block;
    *display:inline;
    zoom:1;
	width:35px;
	height:20px;	
	margin:10px;
	line-height:18px;
	text-align:center;
}
.pageBox{
	border:1px solid #ccc;
	width:98%;
	text-align:center;
	position:fixed;
	_position:absolute;
	bottom:0px;
	_bottom:0px;
	_margin-top:expression(this.style.pixelHeight+document.documentElement.scrollTop)
}
</style>
<script type="text/javascript">
function chooseChannelName(trNum) {
	var a = document.getElementById("channelTableABC");
	for ( var i = 1; i < a.rows.length; i++) {
		a.rows[i].className = "rowsOne";
	}
	trNum.className = "rowsTwo";
	parent.$.returnValue = trNum.cells[0].innerHTML + "|:,:|" +trNum.cells[1].innerHTML;
}
function trMouseOver(trNum) {
	if (trNum.className != "rowsTwo") {
		trNum.className = "rowsThree";
	}
}
function trMouseOut(trNum) {
	if (trNum.className != "rowsTwo") {
		trNum.className = "rowsOne";
	}
}

var pageRank = 1;
function setPageRank(){
	pageRank = 1;
}

function querySupplier(pageNum) {
	var a = document.getElementById("channelbody");
	var rowLen = a.rows.length;
	for(var i=0;i<rowLen;i++){
		a.deleteRow(i);
		rowLen--;
		i--;
	}
	$.post("../suppliersJson!jsonFindSuppliers.action", {
		"supplierSearch.channelName" : document.getElementById("name_supplier").value,
		"supplierSearch.companyName" : document.getElementById("company_supplier").value,
		"supplierSearch.channelLevel":document.getElementById("level_supplier").value,
		"supplierSearch.contact" : document.getElementById("contact_supplier").value,
		"supplierSearch.collectionName" : document.getElementById("collection_supplier").value,
		"pageNum" : pageNum
	}, function(data){
		document.getElementById("dataSize").innerHTML = data.jsonDataSize;
		var pageDiv = document.getElementById("pageDiv");
		pageDiv.innerHTML = "";
		var str1 = "<div class='divb'><a href='javascript:querySupplier(";
		var str11 = "<div class='divb'><a style='color: red;' href='javascript:querySupplier(";
		var str2 = ")'>";
		var str3 = "</a></div>";
		var str4 = "<div class='divb'><a href='javascript:pageNext(";
		var str5 = "<div class='divb'><a href='javascript:pageReturn(";
		var pagesize = data.jsonPageSize;
		if(data.jsonPageSize > 10*pageRank){
			pagesize = 10*pageRank;
		}
		if(pageRank != 1){
			pageDiv.innerHTML = pageDiv.innerHTML + str5 + pagesize + str2 + "..." + str3;
		}
		for(var i=1+(pageRank-1)*10;i<=pagesize;i++){
			if(i == pageNum){
				pageDiv.innerHTML = pageDiv.innerHTML + str11 + i + str2 + i + str3;
			}else{
				pageDiv.innerHTML = pageDiv.innerHTML + str1 + i + str2 + i + str3;
			}
		}
		if(data.jsonPageSize > 10*pageRank){
			pageDiv.innerHTML = pageDiv.innerHTML + str4 + data.jsonPageSize + str2 + "..." + str3;
		}
		$(data.jsonSuppliers).each(function(){
			var na = a.insertRow(0);
			var na1 = na.insertCell(0);
			var na2 = na.insertCell(0);
			var na3 = na.insertCell(0);
			var na4 = na.insertCell(0);
			var na5 = na.insertCell(0);
			var na6 = na.insertCell(0);
			var na0 = na.insertCell(0); //第1格
			na0.style.display = "none";
		 	na0.innerHTML = this.PChannelNumber;
			na1.setAttribute("align","center");
			na1.innerHTML = this.PCLineCnName;
			na2.setAttribute("align","center");
			na2.innerHTML = this.PCLineTel;
			na3.setAttribute("align","center");
			na3.innerHTML = this.PCLineContact;
			na4.setAttribute("align","center");
			na4.innerHTML = this.PCLineClass;
			na5.setAttribute("align","center");
			na5.innerHTML = this.PCLineCompany;
			na6.setAttribute("align","center");
			na6.innerHTML = this.PCLineName;
			na.onclick = function(){
				chooseChannelName(na);
			}
			na.onmouseover = function(){
				trMouseOver(na);
			}
			na.onmouseout = function(){
				trMouseOut(na);
			}
			//na.setAttribute("onclick","chooseChannelName(this)");
			//na.setAttribute("onmouseover","trMouseOver(this)");
			//na.setAttribute("onmouseout","trMouseOut(this)");
		});
	});
}

function pageNext(pageSize){
	pageRank = pageRank + 1;
	var pageDiv = document.getElementById("pageDiv");
	pageDiv.innerHTML = "";
	var str1 = "<div class='divb'><a href='javascript:querySupplier(";
	var str2 = ")'>";
	var str3 = "</a></div>";
	var str4 = "<div class='divb'><a href='javascript:pageNext(";
	var str5 = "<div class='divb'><a href='javascript:pageReturn(";
	var psize = pageSize;
	if(pageSize > 10*pageRank){	//20
		psize = 10*pageRank;
	}
	if(pageRank != 1){
		pageDiv.innerHTML = pageDiv.innerHTML + str5 + pageSize + str2 + "..." + str3;
	}
	for(var i=1+(pageRank-1)*10;i<=psize;i++){
		pageDiv.innerHTML = pageDiv.innerHTML + str1 + i + str2 + i + str3;
	}
	if(pageSize > 10*pageRank){
		pageDiv.innerHTML = pageDiv.innerHTML + str4 + pageSize + str2 + "..." + str3;
	}
}
function pageReturn(pageSize){
	pageRank = pageRank - 1;
	var pageDiv = document.getElementById("pageDiv");
	pageDiv.innerHTML = "";
	var str1 = "<div class='divb'><a href='javascript:querySupplier(";
	var str2 = ")'>";
	var str3 = "</a></div>";
	var str4 = "<div class='divb'><a href='javascript:pageNext(";
	var str5 = "<div class='divb'><a href='javascript:pageReturn(";
	var psize = pageSize;
	if(pageSize > 10*pageRank){
		psize = 10*pageRank;
	}
	if(pageRank != 1){
		pageDiv.innerHTML = pageDiv.innerHTML + str5 + pageSize + str2 + "..." + str3;
	}
	for(var i=1+(pageRank-1)*10;i<=psize;i++){
		pageDiv.innerHTML = pageDiv.innerHTML + str1 + i + str2 + i + str3;
	}
	if(pageSize > 10*pageRank){
		pageDiv.innerHTML = pageDiv.innerHTML + str4 + pageSize + str2 + "..." + str3;
	}
}
</script>
  
  </head>
  <body>

<div class="pageHeader">
	<div class="">
		<label class="fontdaxiao">
			渠道名称：
		</label>
		<input id="name_supplier" type="text" size="12" class="fontdaxiao" />
		<label class="fontdaxiao">
			供应商公司名：
		</label>
		<input id="company_supplier" type="text" size="12" class="fontdaxiao" />
		<label class="fontdaxiao" >
			级别：
		</label>
		<select id="level_supplier" class="fontdaxiao">
			<option value="">
				全部
			</option>
			<option value="1">
				1
			</option>
			<option value="2">
				2
			</option>
			<option value="3">
				3
			</option>
			<option value="4">
				4
			</option>
			<option value="5">
				5
			</option>
		</select>
		<label class="fontdaxiao">
			联系人：
		</label>
		<input id="contact_supplier" type="text" size="8" class="fontdaxiao" />
		<label class="fontdaxiao">
			采集人：
		</label>
		<input id="collection_supplier" type="text" size="8" class="fontdaxiao" />
		<button type="submit" class="fontdaxiao" onclick="querySupplier(1);setPageRank()">
			查询
		</button>
	</div>
</div>
<div class="pageContent">
	<table id="channelTableABC" width="100%" layoutH="65"
		class="tableAF fontdaxiao" cellpadding="0px" cellspacing="0">
		<thead>
			<tr style="background-image: url('../../../backgroundManager/aoll81.jpg')">
				<th width="20%" align="center">
					渠道名称
				</th>
				<th width="20%" align="center">
					公司名称
				</th>
				<th width="8%" align="center">
					等级
				</th>
				<th width="16%" align="center">
					联系人
				</th>
				<th width="16%" align="center">
					电话
				</th>
				<th width="16%" align="center">
					采集人
				</th>
			</tr>
		</thead>
		<tbody id="channelbody">

		</tbody>
	</table>
</div>
<div class="pageBox">
<div class="diva">首页</div>
<div id="pageDiv" style="display:inline-block;*display:inline;">

</div>
<div class="diva">尾页</div>
<div class="divc">共<span id="dataSize" style="color: red;">0</span>行</div>
</div>
</body>
</html>